

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )

	self.LifeTime = CurTime() + math.Rand( 25, 30 )

	local count = table.Count( BodyGibs )
	local model = BodyGibs[ math.random( 1,count ) ]
	if (model == nil) then model = "models/gibs/antlion_gib_small_3.mdl" end

	self.Entity:SetModel( model )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS ) 
	self.Entity:SetPos(data:GetOrigin() + (VectorRand() * math.random( 1, 6 )))
	local phys = self.Entity:GetPhysicsObject()
	
	if (!phys:IsValid()) then
		self.Entity:Remove()
		print("Error! "..model.." is not a valid prop model!\n")
	end
	
	self.Entity:SetCollisionGroup( COLLISION_GROUP_WEAPON )
	
	if ( phys && phys:IsValid() ) then
	
		phys:Wake()
		phys:SetAngle( Angle( math.random(0,359), math.random(0,359), math.random(0,359) ) )
		phys:SetVelocity((Vector(0,0,3) * math.random( 5, 10 )) + (Vector(math.random(-30,30),math.random(-30,30),math.random(-30,30))))
		phys:AddAngleVelocity(Angle(math.random(-250,250),math.random(-250,250),math.random(-250,250)))
		self.Entity:SetMaterial("ice")
	
	end
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )

	return ( self.LifeTime >= CurTime() ) 
	
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	self.Entity:DrawModel()

end



